package com.lims.admin.dao;

import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

import javacommon.base.*;

import cn.org.rapid_framework.page.*;

import com.lims.admin.model.*;
import com.lims.admin.vo.query.*;

/**
 * @author zzh
 * @version 1.0
 * @since 1.0
 */@Repository @SuppressWarnings("unchecked")
public class DiccolumnsDao extends BaseHibernateDao<Diccolumns,java.lang.String>{
	
	public Class getEntityClass() {
		return Diccolumns.class;
	}
	
	public Page findPage(DiccolumnsQuery query) {
        //XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接 
        // [column] 为PageRequest的属性
		String sql = "select t from Diccolumns t where 1=1 "
			  	+ "/~ and t.colName = {colName} ~/"
			  	+ "/~ and t.chineseName = {chineseName} ~/"
			  	+ "/~ and t.describe = {describe} ~/"
			  	+ "/~ and t.tabId = {tabId} ~/"
				+ "/~ order by [sortColumns] ~/";

        //生成sql2的原因是为了不喜欢使用xsqlbuilder的同学，请修改生成器模板，删除本段的生成
        StringBuilder sql2 = new StringBuilder("select t from Diccolumns t where 1=1 ");
        if(isNotEmpty(query.getObjid())) {
            sql2.append(" and  t.objid = :objid ");
        }
        if(isNotEmpty(query.getColName())) {
            sql2.append(" and  t.colName = :colName ");
        }
        if(isNotEmpty(query.getChineseName())) {
            sql2.append(" and  t.chineseName = :chineseName ");
        }
        if(isNotEmpty(query.getDescribe())) {
            sql2.append(" and  t.describe = :describe ");
        }
        if(isNotEmpty(query.getTabId())) {
            sql2.append(" and  t.tabId = :tabId ");
        }
        if(isNotEmpty(query.getSortColumns())) {
            sql2.append(" order by :sortColumns ");
        }	
        
		return pageQuery(sql,query);
	}
	

}
